<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('offer流程审批')" />
    <th:block th:include="include :: datetimepicker-css" />
    <th:block th:include="include :: select2-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-hrOff-edit" th:object="${hrOff}">
            <input name="id" th:field="*{id}" type="hidden">
            <input name="instanceId" th:field="*{instanceId}" type="hidden">
            <input name="taskId" th:field="*{taskId}" type="hidden">
            <input type="hidden" name="p_COM_comment" />

            <div class="form-group">
                <label class="col-sm-3 control-label is-required">姓名：</label>
                <div class="col-sm-8">
                    <input name="toOffName" th:field="*{toOffName}" class="form-control" type="text" readonly>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label">入职城市：</label>
                <div class="col-sm-8">
                    <select id="city" name="city" class="form-control m-b" th:with="type=${@dict.getType('citys')}" disabled>
                        <option value="">所有</option>
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:selected="${dict.dictValue == hrOff.city}" th:value="${dict.dictValue}" ></option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">入职部门：</label>
                <div class="col-sm-8">
                    <select name="deptId" class="form-control m-b" th:with="deptAll=${@deptService.getDeptAll()}" disabled>
                        <option value="">请选择</option><option th:each="dept : ${deptAll}" th:text="${dept.getShowName()}" th:value="${dept.getDeptId()}"  th:field="*{deptId}"  th:if="${dept.getStatus() != '1' && dept.getDelFlag() == '0' }"  th:hidden="${dept.getStatus() == '1' || dept.getDelFlag() != '0' }" ></option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">入职岗位：</label>
                <div class="col-sm-8">
                    <select name="postId" class="form-control m-b" th:with="postAll=${@postService.getPostAll()}" disabled>
                        <option value="">请选择</option><option th:each="post : ${postAll}" th:text="${post.getPostName()}" th:value="${post.getPostId()}" th:field="*{postId}"  th:hidden="${post.getStatus() == '1'}" ></option>
                    </select>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label is-required">手机号码：</label>
                <div class="col-sm-8">
                    <input id="phonenumber" name="phonenumber" th:field="*{phonenumber}"  placeholder="请输入手机号码" class="form-control" type="text" maxlength="11" readonly>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label is-required">邮箱：</label>
                <div class="col-sm-8">
                    <input id="toOffEmail" name="toOffEmail" th:field="*{toOffEmail}"  class="form-control email" type="text" maxlength="20" placeholder="请输入邮箱" readonly>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label">入职日期：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                        <input name="nonManagerDate" th:value="${#dates.format(hrOff.nonManagerDate, 'yyyy-MM-dd')}"  readonly="readonly"  class="form-control" placeholder="yyyy-MM-dd" type="text" >
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">试用期限：</label>
                <div class="col-sm-8">
                    <input name="probationDate" th:field="*{probationDate}" class="form-control" type="text" readonly>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">offer附件：</label>
                <div class="col-sm-8">
                    <!--<input name="adjunct" th:field="*{adjunct}" class="form-control" type="text">-->
                    <a class="btn btn-success " id="downloadAdjunct" href="javascript:void(0)" >文件下载</a>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">简历附件：</label>
                <div class="col-sm-8">
                    <a class="btn btn-success " id="resumeAdjunct" href="javascript:void(0)" >文件下载</a>
                    <!--<input name="resumeAdjunct" th:field="*{resumeAdjunct}" class="form-control" type="text">-->
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label is-required">薪酬级别审批：</label>
                <div class="col-sm-8">
                    <select name="salaryLevel" class="form-control m-b" th:with="type=${@dict.getType('sys_salary_level_type')}" disabled>
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{salaryLevel}"></option>
                    </select>
                </div>
            </div>


            <div class="form-group">
                <label class="col-sm-3 control-label is-required">薪酬标准审批：</label>
                <div class="col-sm-8">
                    <textarea name="salaryStandard" class="form-control" th:field="*{salaryStandard}" readonly></textarea>
                </div>
            </div>



            <div class="form-group">
                <label class="col-sm-3 control-label">员工入职薪资告知单附件：</label>
                <div class="col-sm-8">
                    <a class="btn btn-success " id="salaryAdjunct" href="javascript:void(0)" >文件下载</a>
                    <!--<input name="salaryAdjunctFile" class="form-control" type="file" required>最大50M/1-->
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label is-required">招聘员姓名：</label>
                <div class="col-sm-8">
                    <input name="recruiterName" class="form-control" maxlength="10" th:field="*{recruiterName}" type="text" readonly>
                </div>
            </div>


            <div class="form-group taskItem">
                <label class="col-sm-3 control-label" for="approved">审批意见：</label>
                <div class="col-sm-8">
                    <select name="p_B_approved" id="approved" class="form-control m-b">
                        <option value="true">同意</option>
                        <option value="false">拒绝</option>
                    </select>
                </div>
            </div>
            <div class="form-group taskItem">
                <label class="col-sm-3 control-label">批注：</label>
                <div class="col-sm-8">
                    <textarea name="comment" class="form-control" ></textarea>
                </div>
            </div>
            <hr />

        </form>
    </div>

    <div class="container-div"  style="height: initial;">
        <div class="row">
            <div class="col-sm-12 search-collapse" hidden>
                <form id="role-form">
                    <input type="hidden" id="instanceId" name="instanceId" th:value="${hrOff.instanceId}">
                    <div class="select-list">
                        <ul>
                            <li>
                                任务名称：<input type="text" name="activityName"/>
                            </li>
                            <li>
                                办理人ID：<input type="text" name="assignee"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search('role-form' , 'bootstrap-table' )"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset('role-form' , 'bootstrap-table')"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="col-sm-12 select-table ">
                <table id="bootstrap-table" ></table>
            </div>
        </div>
    </div>

    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <th:block th:include="include :: select2-js" />
    <script th:inline="javascript">
        var prefix = ctx + "hr/hrOff";
        $("#form-hrOff-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                if ($('textarea[name="comment"]').val()) {
                    $('input[name="p_COM_comment"]').val($('textarea[name="comment"]').val());
                }
                var taskId = [[${taskId}]];
                $.operate.save(prefix + "/complete/" + taskId, $('#form-hrOff-edit').serialize());
            }
        }
        
    </script>

    <script th:inline="javascript">
        var prefixhistory = ctx + "process/general";

        $(function() {
            var options = {
                url: prefixhistory + "/listHistory",
                fromId: 'role-form',
                queryParams: queryParams,
                sortName: "createTime",
                sortOrder: "desc",
                modalName: "审批历史",
                showSearch: false,
                showRefresh: false,
                showToggle: false,
                showColumns: false,
                clickToSelect: false,
                rememberSelected: false,
                columns: [{
                    field: 'activityId',
                    title: '活动ID',
                    visible: false
                },
                    {
                        field: 'activityName',
                        title: '任务名称'
                    },
                    {
                        field: 'assignee',
                        title: '处理人ID',
                        visible: true
                    },
                    {
                        field: 'assigneeName',
                        title: '处理人'
                    },
                    {
                        field: 'isApproved',
                        title: '审批状态'
                    },
                    {
                        field: 'comment',
                        title: '审批意见'
                    },
                    {
                        field: 'startTime',
                        title: '开始时间'
                    },
                    {
                        field: 'endTime',
                        title: '结束时间'
                    },
                    {
                        field: 'durationInMillis',
                        title: '耗时',
                        formatter: function(value, row, index) {
                            if (!value) return '未知';
                            return formatTotalDateSub(value / 1000);
                        }
                    }]
            };
            $.table.init(options);
        });

        function queryParams(params) {
            // debugger
            var search = $.table.queryParams(params);
            search.instanceId = $("#instanceId").val();
            return search;
        }

        $("input[name='nonManagerDate']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });
        /* 添加用户-选择用户-提交 */
        /*function submitHandler() {
            $.modal.close();
        }*/



        $("#downloadAdjunct").click(function(){
            var adjunct = [[${hrOff.adjunct}]];
            window.location.href = ctx + "common/download/resource?resource=" + adjunct;
        });
        $("#resumeAdjunct").click(function(){
            var resumeAdjunct = [[${hrOff.resumeAdjunct}]];
            window.location.href = ctx + "common/download/resource?resource=" + resumeAdjunct;
        });
        $("#salaryAdjunct").click(function(){
            var salaryAdjunct = [[${hrOff.salaryAdjunct}]];
            window.location.href = ctx + "common/download/resource?resource=" + salaryAdjunct;
        });
    </script>
</body>
</html>
